package com.danieldura.highrise.data
{
	import com.adobe.utils.DateUtil;
	
	public class Comment implements HighriseData
	{
		public var id:int;
		public var parentId:int;
		public var authorId:int;
		public var createdAt:Date;
		public var body:String;
		
		public function parse( data:XML ):void
		{
			id = data.id;
			parentId = data["parent-id"];
			authorId = data["author-id"];
			createdAt = DateUtil.parseW3CDTF( data["created-at"] );
			body = data.body;
		}
		
		public function toXML():XML
		{
			var data:XML = new XML( <comment /> );
			data.id = id;
			data["parent-id"] = parentId;
			data["author-id"] = authorId;
			data.body = body;
			return data;
		}
		
		public function toXMLString():String
		{
			return toXML().toXMLString();
		}
			
	}
}

/*
<comment>
  <id type="integer">1</id>
  <parent-id type="integer">2</parent-id>
  <author-id type="integer">1</author-id>
  <created-at type="datetime">2006-05-19T20:26:00Z</created-at>
  <body>I agree, taxes are no fun</body>
</comment>
*/